#include "myhead.h"
int main()
{
    char *json_str="{\"姓名\":\"马云\",\"性别\":\"男\",\"年龄\":20,\"isStudent\":\"false\",\"地址\":{\"城市\":\"北京\",\"国家\":\"中国\"},\"成绩\":[\"不合格\",\"合格\",95,96]}";//数组类型必须相等
    cJSON *obj=cJSON_Parse(json_str);//把信息存进链表

    //获取对象的键值对,键值对的信息
    cJSON *vall=cJSON_GetObjectItem(obj,"姓名");
    printf("%s\n",vall->valuestring);
    printf("%s\n",vall->next->valuestring);
    vall=cJSON_GetObjectItem(obj,"年龄");
    printf("%d\n",vall->valueint);
    printf("%s\n",vall->next->valuestring);
    vall=cJSON_GetObjectItem(obj,"地址");
    vall=cJSON_GetObjectItem(vall,"城市");
    printf("%s\n",vall->valuestring);
    vall=cJSON_GetObjectItem(obj,"地址");
    vall=cJSON_GetObjectItem(vall,"国家");
    printf("%s\n",vall->valuestring);
    cJSON *array=cJSON_GetObjectItem(obj,"成绩");
    cJSON *num1=cJSON_GetArrayItem(array,0);
    printf("%s\n",num1->valuestring);
    printf("%s\n",num1->next->valuestring);
    num1=cJSON_GetArrayItem(array,2);
    printf("%d\n",num1->valueint);
    printf("%d\n",num1->next->valueint);
    int a_num = cJSON_GetArraySize(array);
    printf("%d\n",a_num);

    cJSON_Delete(obj);//只释放跟对象
}